<template>
  <div class="remoteconfiguration">
    <div class="con">
        <div class="boxcon">
            当前状态: {{nowStatus ? '连接' : '断开'}}
        </div>
        <div class="boxcon">
            <el-button type="primary"  @click="lianjianfn('连接')">连接</el-button>
        </div>
        <div class="boxcon">
            <el-button type="primary"  @click="lianjianfn('断开')">断开</el-button>
        </div>
       
    </div>
  </div>
</template>

<script>
  import { remoteConfigEnable,remoteConfigDisable,remoteConfigStatus} from "../../api/dataComparisonApi";
export default {


  data() {
    return {
       nowStatus:{}
    };
  },

  mounted() {
    this.getlist()
  },

  methods: {
    lianjianfn(type){
        if(type == '连接'){
            remoteConfigEnable().then(res => {
                if(res.code == 200){
                     this.getlist()
                    this.$message({showClose: true,message: '连接成功',type: 'success'});
                }else {
                     this.$message({showClose: true,message: '连接失败，'+res.msg,type: 'error'});
                }
            })
        }else {
             remoteConfigDisable().then(res => {
                if(res.code == 200){
                     this.getlist()
                    this.$message({showClose: true,message: '断开成功',type: 'success'});
                }else {
                     this.$message({showClose: true,message: '断开失败，'+res.msg,type: 'error'});
                }
            })
        }
    },
    getlist(){
        remoteConfigStatus().then(res => {
            
            if(res.code == 200){
               this.nowStatus = res.data
            }
        })
    }
  },
};
</script>
<style lang="scss" scoped>
    .remoteconfiguration {
         width:100%;
         height: 100%;
         .con {
             width:100%;
             height: 100%;
             background-color: #fff;
             padding: 20px;
             box-sizing: border-box;
             .boxcon {
                 margin-bottom: 30px;
             }
         }
    }
</style>